﻿using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;

namespace Micro.Extensions.Bridge
{
    public interface IBridge
    {

        /// <summary>
        /// 请求
        /// </summary>
        /// <param name="serviceName">服务名</param>
        /// <param name="api">api</param>
        /// <param name="headers">头信息</param>
        /// <returns></returns>
        Task<string> GetStringAsync(string serviceName, string api, Dictionary<string, string> headers = null);

        /// <summary>
        /// 请求
        /// </summary>
        /// <typeparam name="T">返回请求对象</typeparam>
        /// <param name="serviceName">服务名</param>
        /// <param name="api">api 名称</param>
        /// <param name="headers"></param>
        /// <returns></returns>
        Task<T> GetAsync<T>(string serviceName, string api, Dictionary<string, string> headers = null);
        /// <summary>
        /// 获取响应
        /// </summary>
        /// <param name="serviceName"></param>
        /// <param name="api"></param>
        /// <param name="headers"></param>
        /// <returns></returns>
        Task<HttpResponseMessage> GetResponseAsync(string serviceName, string api, Dictionary<string, string> headers = null);

        /// <summary>
        /// 发起post请求
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="serviceName">服务名</param>
        /// <param name="api">api</param>
        /// <param name="jsonContent">json体</param>
        /// <param name="headers">头部信息</param>
        /// <returns>响应结构</returns>
        Task<T> PostAsync<T>(string serviceName, string api, string jsonContent, Dictionary<string, string> headers = null);

        /// <summary>
        /// 发起ppost 请求
        /// </summary>
        /// <param name="serviceName">服务名</param>
        /// <param name="api">api</param>
        /// <param name="jsonContent">json 体</param>
        /// <param name="headers">头信息</param>
        /// <returns>响应</returns>
        Task<HttpResponseMessage> PostResponseAsync(string serviceName, string api, string jsonContent, Dictionary<string, string> headers = null);
        /// <summary>
        /// 发起put
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="serviceName">服务名</param>
        /// <param name="api">api</param>
        /// <param name="jsonContent">json请求体</param>
        /// <param name="headers">头信息</param>
        /// <returns>响应</returns>
        Task<T> PutAsync<T>(string serviceName, string api, string jsonContent, Dictionary<string, string> headers = null);

        /// <summary>
        /// 发起Delete请求
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="serviceName">服务名</param>
        /// <param name="api">api</param>
        /// <param name="headers">头信息</param>
        /// <returns>响应</returns>
        Task<T> DeleteAsync<T>(string serviceName, string api, Dictionary<string, string> headers = null);

        /// <summary>
        /// send 请求
        /// </summary>
        /// <param name="serviceName">服务名</param>
        /// <param name="request">api</param>
        /// <param name="headers">头信息</param>
        /// <returns>>响应</returns>
        Task<HttpResponseMessage> SendAsync(string serviceName, HttpRequestMessage request, Dictionary<string, string> headers = null);
    }
}
